<meta charset="UTF-8">
<div class="container">
	<h2 style="text-align: center;">班级成绩管理</h2>
	<form class="form-inline">
		<div class="form-group mb-2">
			<div class="input-group">
				<label class="">选择班级：</label> <span> <input
					class="form-control" name="bjcom" id="bjcom" style="padding: 30" /></span>
				<div class="input-group-append" id="button-addon4">
					
				</div>
			</div>
			<div class="input-group">
				<label style="margin-left: 8px">选择课程：</label> <span> <input
					class="form-control" name="kccom" id="kccom" style="padding: 30" />
				</span>
				<div class="input-group-append" id="button-addon4">
					
				</div>
			</div>
			<div class="input-group">
				<button style="margin-left: 20px" type="button"
					class="btn btn-primary glyphicon glyphicon-search " id="cx1">查询</button>
			</div>
		</div>
	</form>
</div>
<div id="div2" style="flex-grow: 1; display: none;">
	<table id="bjcj1">
		<thead>
			<tr>
				<th width="200" data-field='student.stuNo'>学号</th>
				<th width="300" data-field='student.name'>姓名</th>
				<th width="300" data-field='course.name'>课程</th>
				<th width="200" data-field='grade'
					formatter=" formatOper(val, row, index)">成绩</th>
			</tr>

		</thead>

	</table>
</div>
<script type="text/javascript">
			$('#bjqc').bind('click',function(){
				$('#bjcom').combobox('setNull');
				$('#div2').hide();
			})
			$('#kcqc').bind('click',function(){
				$('#kccom').combobox('setNull');
				$('#div2').hide();
			})
			$('#bjcom').combobox({
				textField:'name',
				valueField:'id',
				url:'banji/list'
			})
			$('#kccom').combobox({
				textField:'name',
				valueField:'id',
				url:'course/list'
			})
			$(function(){
			
				var grid = $('#bjcj1');
				$('#cx1').bind('click',function(){
					var bjId=$('#bjcom').combobox('getValue');
					var kcId=$('#kccom').combobox('getValue');
					if(bjId==0||kcId==0){
							$('#div2').hide();
							return;
						}else{
							$('#div2').show();
							
					}
				
					grid.datagrid({
						url: 'grade/page?bjId='+bjId+'&kcId='+kcId,
						search: false,
						buttons:[],
						columns:[
							[
							{title:'aa',field:'aa',checkbox:true},
					        {field:'student.tbClass.name',title:'班级'},
					        {field:'student.stuNo',title:'学号'},
					        {field:'student.name',title:'姓名'},
					        {field:'course.name',title:'课程'},
					        {field:'grade',title:'成绩',formatter: function formatOper(val, row, index) {   
					    	 	if(row.grade==null){
		
					    	           row.grade=0;
					    			 	}
		return '<input type="number" class="form-control" onchange="xg('+row.id+',value)" id="input" value="'+row.grade+'"/>';
					    	        }}
					  		  ]
							],
					});
			
				});
				
			})
			
		
			function xg(id,grade){
				if(!(/^[0-9]\d*$/.test(grade))){
					bootbox.alert('请输入正整数');
					return;
				};
			$.post('grade/cjChange',{id:id,grade:grade},function(data){});
		}
	</script>

